<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Mocha Tests</title>
  <link id="mocha-css" href="../node_modules/mocha/mocha.css" rel="stylesheet" />
  <script>
  addEventListener('error', window.__e=function f(e){f.q=f.q||[];f.q.push(e)});
  </script>
  <script src="https://www.google-analytics.com/analytics.js"></script>
</head>
<body>
  <div id="mocha"></div>
  <script src="../node_modules/mocha/mocha.js"></script>
  <script>mocha.setup({timeout: 10000, ui: 'bdd'});</script>
  <script src="../build/test.js"></script>
  <script>
    var runner = mocha.run();

    var failedTests = [];
    runner.on('end', function() {
      window.mochaResults = runner.stats;
      window.mochaResults.reports = failedTests;
    });

    runner.on('fail', function(test, err){
      var flattenTitles = function(test){
        var titles = [];
        while (test.parent.title){
          titles.push(test.parent.title);
          test = test.parent;
        }
        return titles.reverse();
      };

      failedTests.push({
        name: test.title,
        result: false,
        message: err.message,
        stack: err.stack,
        titles: flattenTitles(test)
      });
    });
  </script>

  <!-- Note: uncomment when needed. Don't use when running on CI. -->
  <!-- <script src="/node_modules/source-map-support/browser-source-map-support.js"></script> -->
  <!-- <script>sourceMapSupport.install();</script> -->
</body>
</html>
